#!/bin/bash

# 设置虚拟环境名称和目录
VENV_NAME="amdstable-diffusion/bin/activate"
VENV_DIR="/home/amd/stable-diffusion"

#清除 pip 缓存  删除 amdsmi 相关的本地安装文件
sudo python3 -m pip uninstall amdsmi -y
python3 -m pip cache purge
sudo rm -rf ~/.local/lib/python3.10/site-packages/amdsmi* ~/.local/lib/python3.10/site-packages/*-qdm*

# 安装 amd-smi-lib
sudo apt update
sudo apt install -y amd-smi-lib
sudo chown -R $(whoami) /opt/rocm/share/amd_smi
cd /opt/rocm/share/amd_smi
python3 -m pip install --upgrade pip
sudo python3 -m pip install --user .

# 安装虚拟环境目录中的 Python 包
cd $VENV_DIR
source $VENV_NAME
cd /opt/rocm/share/amd_smi 
pip install .